using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DeleteParametersPage : System.Web.UI.Page
{
    GridView gridView;
    SqlDataSource sqlDataSource;
    protected void Page_Load(object sender, EventArgs e)
    {
        sqlDataSource = new SqlDataSource();
        sqlDataSource.ConnectionString =
        WebConfigurationManager.ConnectionStrings[
            "RecruitVietnamDbConnectionString"
            ].ConnectionString;
        ShowData();
        DeleteRecord("7");
        ShowData();
    }

    void ShowData()
    {
        sqlDataSource.SelectCommandType =
                SqlDataSourceCommandType.Text;
        sqlDataSource.SelectCommand =
        "select * from tblProvinces";
        gridView = new GridView();
        this.form1.Controls.Add(gridView);
        gridView.DataSource = sqlDataSource;
        gridView.DataBind();

    }

    void DeleteRecord(string provinceID)
    {

        sqlDataSource.DeleteCommandType =
        SqlDataSourceCommandType.Text;
        sqlDataSource.DeleteCommand =
        "Delete from tblProvinces " +
        " where ProvinceID=@ProvinceID";
        Parameter parameter = new
        Parameter("ProvinceID",
        TypeCode.String, provinceID);
        sqlDataSource.DeleteParameters.Add(parameter);
        sqlDataSource.Delete();


    }
}
